#include "FFmpegDecoder.hpp"

bool FFmpegDecoder::load(const char* filename, bool silence) {
    /*av_register_all();
    codec=NULL;
    formatContext=NULL;
    if(avformat_open_input(*formatContext, filename, NULL,NULL)) {
        std::cerr<<"FFmpeg: cannot open file: "<<filename<<std::endl;
        return false;
    }
    codec=avcodec_find_decoder(formatContext->audio_codec_id);
    if (avformat_find_stream_info(formatContext, NULL) < 0) {
        std::cerr<<"FFmpeg: cannot find file info: "<<filename<<std::endl;
        return false;
    }
    int stream_id=-1;
    //find the first audio stream
    for (int i = 0; i < formatContext->nb_streams; i++)
        if (formatContext->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) {
            stream_id = i;
            break;
        }
    if (stream_id==-1) {
        std::cerr<<"FFmpeg: cannot find an audio stream info: "<<filename<<std::endl;
        return false;
    }*/
    //if(av_open_input_file(&formatContext, filename, NULL, 0, NULL)!=0) return false; //cant open file
    //if(av_find_stream_info(formatContext)<0) return false; //cant find strem info
    return false;
}

void FFmpegDecoder::close() {
    //avformat_close_input(&formatContext);
    //delete codec;
    //av_close_input_file(&formatContext);
}

int FFmpegDecoder::decode(float *data, unsigned long frames) {
    return -1;
}

bool FFmpegDecoder::seek(unsigned int frame) {
    //av_seek_frame(&formatContext, -1, frame, AVSEEK_FLAG_FRAME);
    return false;
}

FFmpegDecoder::FFmpegDecoder() {

}

FFmpegDecoder::~FFmpegDecoder() {

}
